#include <unistd.h>
#include <fcntl.h>
#include <iostream>
using namespace std;
#include <signal.h>

void signal_handler(int signal){
    cout << "接收到了信号 " << signal << endl;
    exit(signal);
}

int main(int argc, char const *argv[])
{
    
    if( signal(SIGINT,signal_handler) == SIG_ERR){
        perror("注册失败");
        exit(EXIT_FAILURE);
    }

    while(true){
        cout << "你好，在吗？给我信号+.+" << endl; 
    }
    return 0;
}
